package com.witte.serviceImp;

import com.witte.dao.ProductMapper;
import com.witte.entity.Chance;
import com.witte.entity.Customer;
import com.witte.entity.Product;
import com.witte.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImp implements ProductService {

    @Autowired(required=false)
    ProductMapper productMapper;

    @Override
    public List<Product> selectAll() {
        List<Product> list = productMapper.selectAll();
        return list;
    }

    @Override
    public Product selectByPrimaryKey(String productno) {
        return productMapper.selectByPrimaryKey(productno);
    }

    @Override
    public int deleteByPrimaryKey(String productno){
        int a = productMapper.deleteByPrimaryKey(productno);
        return a;
    }

    @Override
    public int updateByProductNo(Product product) {
        int a = productMapper.updateByPrimaryKey(product);
        return a;
    }

    @Override
    public int insertSelective(Product product) {
        int a = productMapper.insertSelective(product);
        return a;
    }

    @Override
    public List<Product> getListForPage(Integer beginPage, Integer pageSize) {
        int begin = (beginPage-1)*pageSize;
        return productMapper.selectForPage(begin,pageSize);
    }

    @Override
    public int getRecodeCount() {

        return productMapper.getRecodeCount();
    }

    @Override
    public List<Product> getListByProductName(String name, Integer beginPage, Integer pageSize) {
        int begain= (beginPage-1)*pageSize;
        List<Product> list = productMapper.selectByProductName(name,begain,pageSize);
        return list;
    }

    @Override
    public int getNameCount(String name) {
        return productMapper.getNameCount(name);
    }

   /*@Override
   public List<Customer> getNameList(String name, Integer beginPage, Integer pageSize) {
       int begain= (beginPage-1)*pageSize;
       return customerMapper.selectByName(name,begain,pageSize);
   }

    @Override
    public int getNameCount(String name) {
        return customerMapper.getNameCount(name);
    }*/

}
